<?php 
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../DAO/OrdersDAO.php';
class OrdersService
{
	public function create(BaseContext $context, ServiceResult $result, OrdersDomain $ordersDomain)
	{
		try
		{
			$ordersDAO = new OrdersDAO($context);
			$ordersDAO->create($ordersDomain);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function update(BaseContext $context, ServiceResult $result, OrdersDomain $ordersDomain)
	{
		try
		{
			$ordersDAO = new OrdersDAO($context);
			$ordersDAO->update($ordersDomain);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function delete(BaseContext $context, ServiceResult $result, $oid)
	{
		try
		{
			$ordersDAO = new OrdersDAO($context);
			$ordersDAO->delete($oid);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function findByOid(BaseContext $context, ServiceResult $result, $oid)
	{
		try
		{
			$ordersDAO = new OrdersDAO($context);
			$ordersDomain = $ordersDAO->findByOid($oid);
			$result->setSuccess();
			return $ordersDomain;
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function findAll(BaseContext $context, ServiceResult $result)
	{
		try
		{
			$ordersDAO = new OrdersDAO($context);
			$ordersDomainArr = $ordersDAO->findAll();
			$result->setSuccess();
			return $ordersDomainArr;
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

}
?>